package com.qinsoft.test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.qinsoft.business.user.bean.User;
import com.qinsoft.frame.utils.ItemChain;
import com.taobao.api.domain.Item;

public class test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Item i = new Item();
		i.setNumIid(123L);
		i.setNick("zj");
		Item i1 = new Item();
		i1.setNumIid(1234L);
		i1.setNick("zj1");
		ItemChain chain = new ItemChain();
		chain.addNode(i);
		chain.addNode(i1);
		System.out.println(chain.getSize());
		chain.printAll();
		System.out.println(chain.contains("123"));
		chain.deleteNode("123");
		System.out.println(chain.getSize());
		chain.printAll();
		
		String ids[]=new String[]{"120","121","122","124",};
		List<StringBuffer> list = new ArrayList<StringBuffer>();
		int num=0;
        num = (ids.length%2==0)?(ids.length/2):((ids.length/2)+1);
        for(int a=0;a<num;a++){
        	int index = 0;
        	StringBuffer sb = new StringBuffer();
        	for(int j=a*2;j<ids.length;j++,index++){
        		if(index==2){
        			break;
        		}
        		if(j==(2*a+1)){
        			sb.append(ids[j]);
        		}else if(j==ids.length-1){
        			sb.append(ids[j]);
        		}else{
        			sb.append(ids[j]+",");
        		}
        	}
        	list.add(sb);
        }
        for(StringBuffer s : list){
        	System.out.println(s.toString());
        }
        Set<Item> items = new HashSet<Item>();
        Item it = new Item();
        it.setNumIid(123L);
        it.setNick("zj");
        items.add(it);
        Item it1 = new Item();
        it1.setNumIid(123L);
        it1.setNick("zj");
        items.add(it1);
        for (Iterator iter = items.iterator(); iter.hasNext();) {
        	Item u1 = (Item)iter.next();
    		System.out.println(u1.getNick());
    	}
	}
}
